package com.example.healing.controller;

import com.example.healing.common.lang.Result;
import com.example.healing.entity.ListSong;
import com.example.healing.service.ListSongService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author neymar
 * @date 2021年11月30日 15:41
 */
@EnableSwagger2
@RestController
@Api(tags = "用户歌单包含的歌曲")
@RequestMapping("/listsong")
public class ListSongController {

    @Autowired
    private ListSongService listSongService;

    /**
     * @author neymar
     * @date 2021/12/1 22:28
     * @param listSong
     * @return com.example.healing.common.lang.Result
     * @description 向歌单中添加歌曲
     */
    @RequiresAuthentication
    @ApiOperation(value = "向歌单中添加歌曲（需要带token）")
    @PostMapping("")
    public Result create(@Validated @RequestBody @ApiParam("歌曲信息") ListSong listSong) {
        return listSongService.create(listSong);
    }

    /**
     * @author neymar
     * @date 2021/12/1 22:27
     * @param listSong
     * @return com.example.healing.common.lang.Result
     * @description 移除歌单中的歌曲
     */
    @RequiresAuthentication
    @ApiOperation(value = "移除歌单中的歌曲（需要带token）")
    @DeleteMapping("")
    public Result delete(@Validated @RequestBody @ApiParam("歌曲信息") ListSong listSong) {
        return listSongService.delete(listSong);
    }

    /**
     * @author neymar
     * @date 2021/12/1 22:27
     * @param listId
     * @return com.example.healing.common.lang.Result
     * @description 获取歌单歌曲
     */
    @RequiresAuthentication
    @ApiOperation(value = "获取歌单歌曲（需要带token）")
    @GetMapping("/{listId}")
    public Result getSongList(@ApiParam("歌单id") @PathVariable("listId") String listId) {
        return listSongService.getSongList(listId);
    }
}
